// 红绿灯async    
let sleep  = new Promise((resolve) => {
    setTimeout(resolve,time)
})  

async function changecolor (color,duration){
    await sleep(duration)
}  

async function main() {
    while(true){
        await changecolor('red',1000)
        await changecolor('yellow',2000)
        await changecolor('green',3000)
    }
}